package cn.javasm.web;

import cn.javasm.entity.Inbound;
import cn.javasm.service.InboundService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author:27chen
 * @className:InboundController
 * @dat:2023/10/24 10:32
 * @version:0.1
 * @since:jdk11
 */
@RestController
@RequestMapping("inbound")
public class InboundController {

    @Autowired
    private InboundService inboundService;

    @GetMapping("inboundFindAll")
    public List<Inbound> inboundList(){
        PageHelper.startPage(1,1);
        List<Inbound> inboundList = inboundService.AllboundList();
        return inboundList;
    }

    @PostMapping("inboundAdd")//post请求
    public String  inboundAdd(@RequestBody Inbound inbound){
        int add = inboundService.add(inbound);
        System.out.println(add);
        return "success";
    }

    @PutMapping("updateInbound")//put请求
    public String updateInbound (@RequestBody Inbound inbound){
        System.out.println(inboundService.update(inbound));
        return "success";
    }

    @DeleteMapping("deleteInboundByCode")
    public  String deleteInboundByCode(Long code){
        inboundService.deleteByCode(code);
        return "success";
    }
}
